package cn.deathgun.dcswebspringboot.mapper

import cn.deathgun.dcswebspringboot.entity.PlayerEntity
import com.baomidou.mybatisplus.core.conditions.Wrapper
import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.baomidou.mybatisplus.core.metadata.IPage
import org.apache.ibatis.annotations.Insert
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository
import java.io.Serializable

@Mapper
@Repository
interface PlayerMapper:BaseMapper<PlayerEntity> {
    @Select("select * from player order by pts desc")
    fun listAllPlayers(): List<PlayerEntity>
    @Select("select * from player where name = #{name}")
    fun listPlayerByName(@Param("name") name: String): PlayerEntity
    @Select("select * from player where name like CONCAT('%', #{name}, '%') order by pts desc")
    fun listPlayerByLikeName(@Param("name") name: String): List<PlayerEntity>

    @Select("select * from player where ucid = #{ucid}")
    fun listPlayerByUcid(@Param("ucid") ucid: String): PlayerEntity

    // player (ucid, name, pts, splashAA, splashAG, splashSEAD, splashSHIP, dead, landing)
    @Insert("insert into player (ucid, name) values(#{ucid}, #{name})")
    fun insertNewPlayer(@Param("ucid") ucid:String, @Param("name") name:String): Int
}